﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace MoodleDesktop
{
    public partial class Day : UserControl
    {
        public bool isActiveDay = false;
        public bool isDayPre = false;
        public bool isDayNext = false;
        public bool isClick = false;
        public DateTime date;
        //public delegate void clicktoDay(object sender,EventArgs e);
        //public clicktoDay mySender;
        public Day()
        {
            InitializeComponent();
        }

        private void label_Day_Click(object sender, EventArgs e)
        {
            foreach (Day d in fmCalendar.dsDay)
            {
                if (d.isClick == true)
                {
                    d.BackgroundImage = null;
                    d.isClick = false;
                    break;
                }
            }
            Day_Click(sender, e);
            if (!isActiveDay && (this.date.Day != DateTime.Now.Day))
            {
                this.BackgroundImage = Resource1.Clickday;
                isClick = true;
            }
            if (isActiveDay)
            {
                // Ngày này có deadline
                if (fmCalendar.forum != null)
                    fmCalendar.forum.Close();
                fmCalendar.forum = new fmForum();
                fmCalendar.forum.Location = new Point(fmCalendar.vitri.X - fmCalendar.forum.Width, fmCalendar.vitri.Y);
                fmCalendar.forum.Show();
                //System.Diagnostics.Process.Start("chrome.exe", "http://courses.fit.hcmus.edu.vn/login/index.php");
                System.Diagnostics.Process proc = new System.Diagnostics.Process();

                proc.EnableRaisingEvents = false;

                proc.StartInfo.FileName = "http://courses.fit.hcmus.edu.vn/mod/resource/view.php?id=60965";

                proc.Start();
            }
            
            
        }

        private void Day_Click(object sender, EventArgs e)
        {
            //this.mySender(sender, e);

        }
    }
}
